﻿/**
*发放意向书编号
*/
Chenxin.UI.LetterCodeDeliverForm = Chenxin.extend(Chenxin.UI.FormCommon,{
    actionUrl:'/service/logic/ShowListIntent.ashx',
    id:'jqmdelivercode',
    renderTo:'div_delivercode',
    winCls:'',
    jqmWidth:700,
    defBBtn:true,
	op:'letterofintentdeliver',
    createForm: function() {
        return Chenxin.FormCommon.LetterCodeDeliverForm(this.id);
    },
	customerFormVal:function(model){
		if(!model.userid){
			alert('请选择人员');
			return false;
		}
		return true;
	},
	createGrid:function(){		
        return new Chenxin.UI.JsonGrid({
            actionUrl: this.actionUrl + '?op=getdeliverlist',
            id: 'delivercode_grid',
			modelId:'IntentionId',
            renderTo: this.id+'_grid',
            hasCheckBox:true,
            cellBorder:true,
            scope:this,
			autoLoad:false,
			pageSize:10,
			hasCheckBox:false,
            columns: {
                IntentionId:{
					create:false,
					head:'id'
				},
                IntentionCode: {
                    head: '意向书编号',
                    width: 180
                },
                BusinessType: {
                    head: '业务类型',
					renderer:function(val){
						if(val==10){
							return '买卖';
						}else if(val==20){
							return '租赁';
						}
						return '';
					},
                    width: 70
                },
                IntentionType: {
                    head: '意向类型',
                    width: 70,
					renderer:function(val){
						if(val==10){
							return '买卖协议';
						}else if(val==20){
							return '居间协议';
						}
						return '';
					}
                },
                CreateDate: {
                    head: '时间',
                    width: 120,
					renderer:function(val){
						return val.substr(0,10);
					}
                },
				operate:{
					head:'操作',
					width:80,
					renderer:function(val,c,row){
						return '<a title="移除" id='+row.IntentionId+' class="x-row-remove" style="cursor:pointer">移除</a>';
					}
				}
            }
        });
	},
    createComboList:function(){
        //五级联Combo
        var combl = new Chenxin.UI.StructComboList({
            comboContainerId:{
		        city:'#'+this.id+'_city',
		        company:'#'+this.id+'_company',
		        businessDistrict:'#'+this.id+'_businessdistrict',
		        departs:'#'+this.id+'_departs',
		        employee:'#'+this.id+'_employee'
	        },
	        inModelType:'all',
			tbxWidth:50,
	        comboTxtModelNameConfig:{
			    city:'city',
			    company:'company',
			    businessDistrict:'area',
			    departs:'depart',
			    employee:'user'			
		    }
        });
        var structs = combl.comboList;
        return structs;
    },
	initGridEvent:function(){
		var _this=this;
		$('.x-row-remove').live('click',function(){
			_this.grid.deleteRecord(this.id);
			_this.grid.reRender();
		});
	},
    saveSucc: function() {
        this.reloadGrid();
    },
    initComponent: function() {
        Chenxin.UI.LetterCodeDeliverForm.superclass.initComponent.call(this);
		this.grid=this.createGrid();
		this.initGridEvent();
    }
});

Chenxin.FormCommon.LetterCodeDeliverForm=function(formID){
return '<table style="width:100%;margin:5px 0px;"><tbody><tr><td style="width:40px;text-align:right;">城市：</td><td><div id="'+formID+'_city" style="z-index:883; margin-right: 2px;" class="SelectWrapSingle"></div></td><td style="width:40px;text-align:right;">公司：</td><td><div id="'+formID+'_company" style="z-index:822; margin-right: 2px;" class="SelectWrapSingle"></div></td><td style="width:40px;text-align:right;">商圈：</td><td><div id="'+formID+'_businessdistrict" style="z-index:811; margin-right: 2px;" class="SelectWrapSingle"></div></td><td style="right:40px;text-align:right;">部门：</td><td><div id="'+formID+'_departs" style="z-index:800; margin-right: 2px;" class="SelectWrapSingle"></div></td><td style="width:40px;text-align:right;">人员：</td><td><div id="'+formID+'_employee"style="z-index:779; margin-right: 2px;" class="SelectWrapSingle"></div></td></tr></tbody></table><div id="'+formID+'_grid"></div>';
};